let mutDoneCount = 'mutDoneCount'
export default {
  state: {
    todos: [
      { id: 1, done: true },
      { id: 2, done: false }
    ],
    count: 1
  },
  getters: {
    doneTodos: (state, getters) => {
      console.log(state, getters);
      return state.todos.filter(todo => todo.done)
    },
    doneCount: (state, getters, rootGetters) => {
      console.log(state, getters, rootGetters);
      return state.count
    },
  },
  mutations: {
    mutDoneTodos(state) {
      state.todos.push({
        id: new Date().getTime(), done: true
      })
    },
    [mutDoneCount](state, state1) {
      state.count++;
      console.log(state, state1)
    }
  }
}

/**
  getters会接收state作为第一个参数, 接收getters为第二个参数
 在使用时
 1. 通过属性访问 store.getters.id
 2. 通过方法访问 让getter返回一个函数，来实现给getter传参
 使用mapGetters辅助函数
  1. computed: mapGetters(['value'])  value => this.$store.getters.value
  2. 混合使用
    computed: {
      ...mapGetters(['value'])
    }
  3. 另起一个名字
    computed: {
      ...mapGetters({
        newName: value
      })
    }
 */
